<!DOCTYPE html>
<html>
<head>
    <title>for loop and if</title>
</head>
<body>

{% for item in list %}
{{ item }}{% if not forloop.last %},{% endif %}
{% endfor %}
<a href="{% url 'homepage' %}">home</a>
 
</body>
</html>